import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post } from '@midwayjs/core';
import { Validate } from '@midwayjs/validate';
import { GradeDTO } from '../../dto/grade';
import { RouterService } from '../../service/router/router';

/**
 * 成绩
 */
@CoolController()
export class GradeController extends BaseController {
    @Inject()
    RouterService: RouterService;

    /**
     * 成绩查询
     * @param year 学年
     * @param term 学期
     */
    @Post('/grade', { summary: '成绩查询' })
    @Validate()
    async get_grade(@Body() params: GradeDTO) {
        const { year, term } = params;
        const { success, message, data } = await this.RouterService.get_grade(year, term);
        if (!success) return this.fail(data, message);
        return this.ok(data, message);
    }
}